package com.pmcc.core.repository;

import com.pmcc.core.entity.security.Region;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by lihaiyue on 2018/3/28.
 */
public interface RegionRepository extends JpaRepository<Region, String> {

    List<Region> findByParentIdOrderByCode(String parentId);

    @Query(value = "SELECT * FROM sys_tencent_region WHERE id LIKE '%00' ORDER BY short_pinyin,id", nativeQuery = true)
    List<Region> queryForH5();

    @Query(value = "SELECT * FROM sys_tencent_region WHERE id LIKE '%00' AND FULL_NAME LIKE ?1 ORDER BY short_pinyin,id", nativeQuery = true)
    List<Region> queryBySql(String name);

}
